<?php
defined( '_VALID_MOS' ) or die('<script>window.location.href="http://www.kinifurniture.com";</script>');

$adm_functions->is_admin_login();
$section='Add Collection';
$icon_description='
<table><tr><td>
	<table cellspacing="0" cellpadding="4" border="0" align="center">
		<tr align="center">
			<td>
				<img src="show_files/publish1.png" border="0" alt="Pending" />
			</td>
			<td>
				News is <u>inactive</u> |
			</td>
			<td>
				<img src="show_files/tick.png" border="0" alt="Visible" />
			</td>
			<td>
				News is <u>active</u>  |
			</td>
			<td>
				<img src="show_files/delete.png" border="0" alt="Visible" />
			</td>
			<td>
				<u>Delete</u> News
			</td>
		</tr>
	</table>
</td></tr><tr><td align="center">
	<table cellspacing="0" cellpadding="4" border="0" align="center">
		<tr align="center">
			<td align="center">
				<i>Click on icon to toggle state or execute command.</i>
			</td>
		</tr>
	</table>
</td></tr></table>
';
$adm_menu='
<table width="100%" class="menubar" cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td class="menudottedline" width="40%">
			<div class="pathway"><img src="assets/admin/'.$SITE_LOGO_ADMIN.'"/></div>	</td>
		<td class="menudottedline" align="right">
			<table cellpadding="0" cellspacing="0" border="0" id="toolbar">
				<tr valign="middle" align="center">
					<td>&nbsp;</td>
					<td>
					<a class="toolbar" href="javascript:kliksubmit();">
						<img src="show_files/save.png"  alt="Save" name="save" title="Save" align="middle" border="0" />				<br />Save</a>
					</td>
					<td>&nbsp;</td>
					<td>
						<a class="toolbar" href="admin.php?show=collection_manager">
						<img src="show_files/cancel.png"  alt="Cancel" name="cancel" title="Cancel" align="middle" border="0" />				<br />Cancel</a>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<br />
';
$val_select1='selected';
$val_select2='';
$val_select3='selected';
$val_select4='';
$val_select5='selected';
$val_select6='';
$val_select7='';
if($inp_title)
{
	if($_FILES['inp_upl_img']['name'])
	{
		$img_name=basename($_FILES['inp_upl_img']['name']);
		$qryname="select * from koleksi where image='$img_name'";
		$selectname=$dbh->query($qryname);
		$imageexists=mysql_num_rows($selectname);
		
		if($imageexists>0)
		{
			echo '<script>alert("The Filename is already exists, try another filename");</script>';
			$val_title=$inp_title;
			if ($inp_indoor=='Y') $val_select1='selected'; else $val_select2='selected';
			if ($inp_outdoor=='Y') $val_select3='selected'; else $val_select4='selected';
			if ($inp_typeofwood=='EOA') $val_select5='selected';
			if ($inp_typeofwood=='RTW') $val_select6='selected';
			if ($inp_typeofwood=='VTW') $val_select7='selected';
			$val_description=$inp_description;
		}
		else
		{
			$uploaddir = 'assets/collection/';
			$uploadfile = $uploaddir . basename($_FILES['inp_upl_img']['name']);
			move_uploaded_file($_FILES['inp_upl_img']['tmp_name'], $uploadfile);
			$img_name=basename($_FILES['inp_upl_img']['name']);
		}
	} else 	$img_name='';
	if ($imageexists==0) 
	{
		$dbh->query("insert into koleksi (nama, image, deskripsi, indoor, outdoor, typeofwood) values
			('$inp_title', '$img_name', '$inp_description', '$inp_indoor', '$inp_outdoor', '$inp_typeofwood')");
		echo '<script>alert("Added New Collection");</script>';
		echo '<script>window.location.href="admin.php?show=collection_manager";</script>';
	}
}
?>